#ifndef __lcd_h
#define __lcd_h

#define	lcd_spi		QSPI2

//extern DMA_ChnInitTypeDef DMA_ChnInitStruct;
void spi_init(void);
void spi_dma(u16 cnt,u32 addr_src);
#define spi_cs_AHB		RCC_AHBPeriphClkEn_GPIOA
#define spi_cs_gpio		GPIOA
#define spi_cs_pin		GPIO_Pin_2
#define spi_cs_pinscr	GPIO_PinSource2
#define spi_cs_AF		PA2_QSPI2_NSS

#define spi_scl_AHB		RCC_AHBPeriphClkEn_GPIOA
#define spi_scl_gpio	GPIOA
#define spi_scl_pin		GPIO_Pin_0
#define spi_scl_pinscr	GPIO_PinSource0
#define spi_scl_AF		PA0_QSPI2_SCK

#define spi_sda_AHB		RCC_AHBPeriphClkEn_GPIOA
#define spi_sda_gpio	GPIOA
#define spi_sda_pin		GPIO_Pin_4
#define spi_sda_pinscr	GPIO_PinSource4
#define spi_sda_AF		PA4_QSPI2_MOSI

#define spi_DC_AHB		RCC_AHBPeriphClkEn_GPIOA
#define spi_DC_gpio		GPIOA
#define spi_DC_pin		GPIO_Pin_1
#define spi_DC_data()	GPIO_WriteBit(spi_DC_gpio,spi_DC_pin,Bit_SET)
#define spi_DC_cmd()	GPIO_WriteBit(spi_DC_gpio,spi_DC_pin,Bit_RESET)


#define lcd_reset_AHB	RCC_AHBPeriphClkEn_GPIOA
#define lcd_reset_gpio	GPIOA
#define lcd_reset_pin	GPIO_Pin_3


#define	lcd_cs_enable(x)		SPI_Read_Cmd(lcd_spi, DISABLE);   \
								SPI_SendCommand(lcd_spi, x);\
								SPI_Lock_CS_Cmd(lcd_spi, ENABLE);\
								SPI_RunCmd(lcd_spi, ENABLE)      ;\
								while (SPI_GetBusyStatus(lcd_spi) == SET){}

#define lcd_cs_disable()		SPI_RunCmd(lcd_spi, DISABLE);     \
								SPI_Lock_CS_Cmd(lcd_spi, DISABLE)
									
#define lcs_spi_senddata(x)		SPI_SendData(lcd_spi, x); \
								while (SPI_GetBusyStatus(lcd_spi) == SET){}

#define lcd_cmd_wr_ram	0x2c
extern u8 state_dma;
void Init_LCD(void);
void disp_color(u16 color);		
void spi_write_cmd(u8 cmd);
void lcd_setsize(u16 x_start, u16 x_end, u16 y_start, u16 y_end);
void lcd_send_arr(const u8* arr,u32 cnt);
void lcd_send_arr_(const u16* arr,u32 cnt);
void lcd_send_num(u16 num,u32 cnt);
void lcd_fps(void);

#endif
